package com.javaspeak.designpatterns.go4.structural.flyweight;

/**
 * ShapeCache is a flyweight factory that returns flyweight shapes.  There is
 * only one instance of each Shape and each Shape may be referenced by many
 * CanvasElements.  This saves on memory.
 *
 * @author John Dickerson
 */
public class ShapeCache {

    private static Shape square = new SquareImpl();
    private static Shape triangle = new TriangleImpl();


    /**
     * @return SquareImpl
     */
    public static Shape getSquare(){

        return square;
    }


    /**
     * @return TriangleImpl
     */
    public static Shape getTriangle(){

        return triangle;
    }
}
